class MyArray<T> {
    public T[] obj = (T[])new Object[10];
    public void setVal(int pos,T val) {
        obj[pos] = val;
    }
    public T getPos(int pos) {
        return obj[pos];
    }
}

class TestDemo<K,V> {
    K k;
    V v;
}

public class Test {
    public static void main(String[] args) {
        MyArray<Integer> myArray = new MyArray<Integer>();   //传数据类型给泛型
        myArray.setVal(0,10);
        int a = myArray.getPos(0);   //取数据不需要强转

        MyArray<String> myArray2 = new MyArray<String>();
        myArray2.setVal(1,"hello");
        String str = myArray2.getPos(1);
    }
}
